package com.gsafety.wellsfort.domain.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.gsafety.wellsfort.common.enums.CustomerTypeEnum;
import com.gsafety.wellsfort.domain.model.knowledge.TeachingMaterial;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;

@Data
@ApiModel(value = "教材")
public class TeachingMaterialVO {
    @ApiModelProperty(value = "教材id")
    private Integer id;

    @ApiModelProperty(value = "教材对象值")
    private Integer objectType;
    @ApiModelProperty(value = "教材对象文本")
    private String objectTypeText;

    @ApiModelProperty(value = "教材文件URL")
    private String fileUrl;

    @ApiModelProperty(value = "标题")
    private String title;

    @ApiModelProperty(value = "关键字")
    private String keyword;

    @ApiModelProperty(value = "启用状态:0禁用1启用")
    private Byte isOpen;


    private Integer creator;
    @ApiModelProperty(value = "添加人名字")
    private String creatorName;


    @ApiModelProperty(value = "添加时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;


    private Integer modified;
    @ApiModelProperty(value = "修改人字")
    private String modifiedName;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "权限列表")
    List<MaterialPrivilegeVO> privilegeList;

    public static  class VOBuilder{
        TeachingMaterial material;
        TeachingMaterialVO materialVo =new TeachingMaterialVO();
        public VOBuilder(TeachingMaterial q){
            this.material =q;
        }
        public TeachingMaterialVO build(){
            BeanUtils.copyProperties(material, materialVo);
            materialVo.setObjectTypeText(CustomerTypeEnum.parseVal(materialVo.getObjectType()).label);
            return materialVo;
        }
    }
}
